

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>BlueStore 配置参考 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/css/custom.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../../_static/favicon.ico"/>
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/jquery.js"></script>
        <script src="../../../_static/underscore.js"></script>
        <script src="../../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../../genindex/" />
    <link rel="search" title="Search" href="../../../search/" />
    <link rel="next" title="filestore 配置参考" href="../filestore-config-ref/" />
    <link rel="prev" title="mClock Config Reference" href="../mclock-config-ref/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../../">Ceph 存储集群</a> &raquo;</li>
        
          <li><a href="../">配置</a> &raquo;</li>
        
      <li>BlueStore 配置参考</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../../../_sources/rados/configuration/bluestore-config-ref.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../../">
          

          
            
            <img src="../../../_static/logo.png" class="logo" alt="Logo"/>
          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../../start/intro/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../cephadm/">Cephadm</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../../">Ceph 存储集群</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="../">配置</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../storage-devices/">存储设备</a></li>
<li class="toctree-l3"><a class="reference internal" href="../ceph-conf/">配置 Ceph</a></li>
<li class="toctree-l3"><a class="reference internal" href="../common/">通用选项</a></li>
<li class="toctree-l3"><a class="reference internal" href="../common/#ceph-network-config">网络</a></li>
<li class="toctree-l3"><a class="reference internal" href="../common/#id3">监视器</a></li>
<li class="toctree-l3"><a class="reference internal" href="../common/#ceph-osd-config">认证</a></li>
<li class="toctree-l3"><a class="reference internal" href="../common/#osds">OSDs</a></li>
<li class="toctree-l3"><a class="reference internal" href="../common/#id5">心跳</a></li>
<li class="toctree-l3"><a class="reference internal" href="../common/#ceph-logging-and-debugging">日志记录、调试</a></li>
<li class="toctree-l3"><a class="reference internal" href="../common/#ceph-conf">ceph.conf 实例</a></li>
<li class="toctree-l3"><a class="reference internal" href="../common/#ceph-runtime-config">跑多个集群（已废弃）</a></li>
<li class="toctree-l3"><a class="reference internal" href="../network-config-ref/">网络选项</a></li>
<li class="toctree-l3"><a class="reference internal" href="../msgr2/">信使协议 v2</a></li>
<li class="toctree-l3"><a class="reference internal" href="../auth-config-ref/">认证选项</a></li>
<li class="toctree-l3"><a class="reference internal" href="../mon-config-ref/">监视器选项</a></li>
<li class="toctree-l3"><a class="reference internal" href="../mon-lookup-dns/">通过 DNS 查询监视器</a></li>
<li class="toctree-l3"><a class="reference internal" href="../mon-osd-interaction/">心跳选项（监视器与 OSD 的的交互）</a></li>
<li class="toctree-l3"><a class="reference internal" href="../osd-config-ref/">OSD 选项</a></li>
<li class="toctree-l3"><a class="reference internal" href="../mclock-config-ref/">DmClock 配置</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">BlueStore 配置</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id1">设备</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id3">调整尺寸</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id4">自动调整缓存尺寸</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id5">手动调整缓存尺寸</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id6">校验和</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id7">内联压缩</a></li>
<li class="toctree-l4"><a class="reference internal" href="#rocksdb-sharding">RocksDB Sharding</a></li>
<li class="toctree-l4"><a class="reference internal" href="#throttling">Throttling</a></li>
<li class="toctree-l4"><a class="reference internal" href="#spdk">SPDK 用法</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../filestore-config-ref/">FileStore 配置</a></li>
<li class="toctree-l3"><a class="reference internal" href="../journal-ref/">日志选项</a></li>
<li class="toctree-l3"><a class="reference internal" href="../pool-pg-config-ref/">存储池、归置组和 CRUSH 选项</a></li>
<li class="toctree-l3"><a class="reference internal" href="../general-config-ref/">常规选项</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../operations/">运维</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../man/">    手册页</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../troubleshooting/">故障排除</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../api/">APIs</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <div class="section" id="bluestore">
<h1>BlueStore 配置参考<a class="headerlink" href="#bluestore" title="Permalink to this headline">¶</a></h1>
<div class="section" id="id1">
<h2>设备<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h2>
<p>BlueStore 可管理一个、两个、或（某些情况下）三个存储设备。</p>
<p>In the simplest case, BlueStore consumes a single (primary) storage device.
The storage device is normally used as a whole, occupying the full device that
is managed directly by BlueStore. This <em>primary device</em> is normally identified
by a <code class="docutils literal notranslate"><span class="pre">block</span></code> symlink in the data directory.</p>
<p>The data directory is a <code class="docutils literal notranslate"><span class="pre">tmpfs</span></code> mount which gets populated (at boot time, or
when <code class="docutils literal notranslate"><span class="pre">ceph-volume</span></code> activates it) with all the common OSD files that hold
information about the OSD, like: its identifier, which cluster it belongs to,
and its private keyring.</p>
<p>It is also possible to deploy BlueStore across one or two additional devices:</p>
<ul class="simple">
<li><p>A <em>write-ahead log (WAL) device</em> (identified as <code class="docutils literal notranslate"><span class="pre">block.wal</span></code> in the data directory) can be
used for BlueStore’s internal journal or write-ahead log. It is only useful
to use a WAL device if the device is faster than the primary device (e.g.,
when it is on an SSD and the primary device is an HDD).</p></li>
<li><p>A <em>DB device</em> (identified as <code class="docutils literal notranslate"><span class="pre">block.db</span></code> in the data directory) can be used
for storing BlueStore’s internal metadata.  BlueStore (or rather, the
embedded RocksDB) will put as much metadata as it can on the DB device to
improve performance.  If the DB device fills up, metadata will spill back
onto the primary device (where it would have been otherwise).  Again, it is
only helpful to provision a DB device if it is faster than the primary
device.</p></li>
</ul>
<p>If there is only a small amount of fast storage available (e.g., less
than a gigabyte), we recommend using it as a WAL device.  If there is
more, provisioning a DB device makes more sense.  The BlueStore
journal will always be placed on the fastest device available, so
using a DB device will provide the same benefit that the WAL device
would while <em>also</em> allowing additional metadata to be stored there (if
it will fit).  This means that if a DB device is specified but an explicit
WAL device is not, the WAL will be implicitly colocated with the DB on the faster
device.</p>
<p>A single-device (colocated) BlueStore OSD can be provisioned with:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">volume</span> <span class="n">lvm</span> <span class="n">prepare</span> <span class="o">--</span><span class="n">bluestore</span> <span class="o">--</span><span class="n">data</span> <span class="o">&lt;</span><span class="n">device</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>To specify a WAL device and/or DB device,</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">volume</span> <span class="n">lvm</span> <span class="n">prepare</span> <span class="o">--</span><span class="n">bluestore</span> <span class="o">--</span><span class="n">data</span> <span class="o">&lt;</span><span class="n">device</span><span class="o">&gt;</span> <span class="o">--</span><span class="n">block</span><span class="o">.</span><span class="n">wal</span> <span class="o">&lt;</span><span class="n">wal</span><span class="o">-</span><span class="n">device</span><span class="o">&gt;</span> <span class="o">--</span><span class="n">block</span><span class="o">.</span><span class="n">db</span> <span class="o">&lt;</span><span class="n">db</span><span class="o">-</span><span class="n">device</span><span class="o">&gt;</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>–data 可以是以 <em>vg/lv</em> 方式表达的逻辑卷。其他设备可以是现有的逻辑卷或 GPT 分区。</p>
</div>
<div class="section" id="id2">
<h3>存储配置策略<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h3>
<p>虽然有多种途径部署后端为 BlueStore 的 OSD （不像 Filestore
只有一种），但是这里的两种常见用法有助于澄清部署策略。</p>
<div class="section" id="block-data-only">
<span id="bluestore-single-type-device-config"></span><h4><strong>block (data) only</strong><a class="headerlink" href="#block-data-only" title="Permalink to this headline">¶</a></h4>
<p>If all devices are the same type, for example all rotational drives, and
there are no fast devices to use for metadata, it makes sense to specifiy the
block device only and to not separate <code class="docutils literal notranslate"><span class="pre">block.db</span></code> or <code class="docutils literal notranslate"><span class="pre">block.wal</span></code>. The
<a class="reference internal" href="../../../ceph-volume/lvm/#ceph-volume-lvm"><span class="std std-ref">lvm</span></a> command for a single <code class="docutils literal notranslate"><span class="pre">/dev/sda</span></code> device looks like:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">volume</span> <span class="n">lvm</span> <span class="n">create</span> <span class="o">--</span><span class="n">bluestore</span> <span class="o">--</span><span class="n">data</span> <span class="o">/</span><span class="n">dev</span><span class="o">/</span><span class="n">sda</span>
</pre></div>
</div>
<p>If logical volumes have already been created for each device, (a single LV
using 100% of the device), then the <a class="reference internal" href="../../../ceph-volume/lvm/#ceph-volume-lvm"><span class="std std-ref">lvm</span></a> call for an LV named
<code class="docutils literal notranslate"><span class="pre">ceph-vg/block-lv</span></code> would look like:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">volume</span> <span class="n">lvm</span> <span class="n">create</span> <span class="o">--</span><span class="n">bluestore</span> <span class="o">--</span><span class="n">data</span> <span class="n">ceph</span><span class="o">-</span><span class="n">vg</span><span class="o">/</span><span class="n">block</span><span class="o">-</span><span class="n">lv</span>
</pre></div>
</div>
</div>
<div class="section" id="block-and-block-db">
<span id="bluestore-mixed-device-config"></span><h4><strong>block and block.db</strong><a class="headerlink" href="#block-and-block-db" title="Permalink to this headline">¶</a></h4>
<p>If you have a mix of fast and slow devices (SSD / NVMe and rotational),
it is recommended to place <code class="docutils literal notranslate"><span class="pre">block.db</span></code> on the faster device while <code class="docutils literal notranslate"><span class="pre">block</span></code>
(data) lives on the slower (spinning drive).</p>
<p>You must create these volume groups and logical volumes manually as
the <code class="docutils literal notranslate"><span class="pre">ceph-volume</span></code> tool is currently not able to do so automatically.</p>
<p>For the below example, let us assume four rotational (<code class="docutils literal notranslate"><span class="pre">sda</span></code>, <code class="docutils literal notranslate"><span class="pre">sdb</span></code>, <code class="docutils literal notranslate"><span class="pre">sdc</span></code>, and <code class="docutils literal notranslate"><span class="pre">sdd</span></code>)
and one (fast) solid state drive (<code class="docutils literal notranslate"><span class="pre">sdx</span></code>). First create the volume groups:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ vgcreate ceph-block-0 /dev/sda
$ vgcreate ceph-block-1 /dev/sdb
$ vgcreate ceph-block-2 /dev/sdc
$ vgcreate ceph-block-3 /dev/sdd
</pre></div>
</div>
<p>Now create the logical volumes for <code class="docutils literal notranslate"><span class="pre">block</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ lvcreate -l 100%FREE -n block-0 ceph-block-0
$ lvcreate -l 100%FREE -n block-1 ceph-block-1
$ lvcreate -l 100%FREE -n block-2 ceph-block-2
$ lvcreate -l 100%FREE -n block-3 ceph-block-3
</pre></div>
</div>
<p>We are creating 4 OSDs for the four slow spinning devices, so assuming a 200GB
SSD in <code class="docutils literal notranslate"><span class="pre">/dev/sdx</span></code> we will create 4 logical volumes, each of 50GB:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ vgcreate ceph-db-0 /dev/sdx
$ lvcreate -L 50GB -n db-0 ceph-db-0
$ lvcreate -L 50GB -n db-1 ceph-db-0
$ lvcreate -L 50GB -n db-2 ceph-db-0
$ lvcreate -L 50GB -n db-3 ceph-db-0
</pre></div>
</div>
<p>Finally, create the 4 OSDs with <code class="docutils literal notranslate"><span class="pre">ceph-volume</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ ceph-volume lvm create --bluestore --data ceph-block-0/block-0 --block.db ceph-db-0/db-0
$ ceph-volume lvm create --bluestore --data ceph-block-1/block-1 --block.db ceph-db-0/db-1
$ ceph-volume lvm create --bluestore --data ceph-block-2/block-2 --block.db ceph-db-0/db-2
$ ceph-volume lvm create --bluestore --data ceph-block-3/block-3 --block.db ceph-db-0/db-3
</pre></div>
</div>
<p>These operations should end up creating four OSDs, with <code class="docutils literal notranslate"><span class="pre">block</span></code> on the slower
rotational drives with a 50 GB logical volume (DB) for each on the solid state
drive.</p>
</div>
</div>
</div>
<div class="section" id="id3">
<h2>调整尺寸<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h2>
<p>When using a <a class="reference internal" href="#bluestore-mixed-device-config"><span class="std std-ref">mixed spinning and solid drive setup</span></a> it is important to make a large enough
<code class="docutils literal notranslate"><span class="pre">block.db</span></code> logical volume for BlueStore. Generally, <code class="docutils literal notranslate"><span class="pre">block.db</span></code> should have
<em>as large as possible</em> logical volumes.</p>
<p>The general recommendation is to have <code class="docutils literal notranslate"><span class="pre">block.db</span></code> size in between 1% to 4%
of <code class="docutils literal notranslate"><span class="pre">block</span></code> size. For RGW workloads, it is recommended that the <code class="docutils literal notranslate"><span class="pre">block.db</span></code>
size isn’t smaller than 4% of <code class="docutils literal notranslate"><span class="pre">block</span></code>, because RGW heavily uses it to store
metadata (omap keys). For example, if the <code class="docutils literal notranslate"><span class="pre">block</span></code> size is 1TB, then <code class="docutils literal notranslate"><span class="pre">block.db</span></code> shouldn’t
be less than 40GB. For RBD workloads, 1% to 2% of <code class="docutils literal notranslate"><span class="pre">block</span></code> size is usually enough.</p>
<p>In older releases, internal level sizes mean that the DB can fully utilize only
specific partition / LV sizes that correspond to sums of L0, L0+L1, L1+L2,
etc. sizes, which with default settings means roughly 3 GB, 30 GB, 300 GB, and
so forth.  Most deployments will not substantially benefit from sizing to
accomodate L3 and higher, though DB compaction can be facilitated by doubling
these figures to 6GB, 60GB, and 600GB.</p>
<p>Improvements in releases beginning with Nautilus 14.2.12 and Octopus 15.2.6
enable better utilization of arbitrary DB device sizes, and the Pacific
release brings experimental dynamic level support.  Users of older releases may
thus wish to plan ahead by provisioning larger DB devices today so that their
benefits may be realized with future upgrades.</p>
<p>When <em>not</em> using a mix of fast and slow devices, it isn’t required to create
separate logical volumes for <code class="docutils literal notranslate"><span class="pre">block.db</span></code> (or <code class="docutils literal notranslate"><span class="pre">block.wal</span></code>). BlueStore will
automatically colocate these within the space of <code class="docutils literal notranslate"><span class="pre">block</span></code>.</p>
</div>
<div class="section" id="id4">
<h2>自动调整缓存尺寸<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h2>
<p>BlueStore can be configured to automatically resize its caches when TCMalloc
is configured as the memory allocator and the <code class="docutils literal notranslate"><span class="pre">bluestore_cache_autotune</span></code>
setting is enabled.  This option is currently enabled by default.  BlueStore
will attempt to keep OSD heap memory usage under a designated target size via
the <code class="docutils literal notranslate"><span class="pre">osd_memory_target</span></code> configuration option.  This is a best effort
algorithm and caches will not shrink smaller than the amount specified by
<code class="docutils literal notranslate"><span class="pre">osd_memory_cache_min</span></code>.  Cache ratios will be chosen based on a hierarchy
of priorities.  If priority information is not available, the
<code class="docutils literal notranslate"><span class="pre">bluestore_cache_meta_ratio</span></code> and <code class="docutils literal notranslate"><span class="pre">bluestore_cache_kv_ratio</span></code> options are
used as fallbacks.</p>
<dl class="std confval">
<dt id="confval-bluestore_cache_autotune">
<code class="sig-name descname"><span class="pre">bluestore_cache_autotune</span></code><a class="headerlink" href="#confval-bluestore_cache_autotune" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>Automatically tune the space ratios assigned to various BlueStore
caches while respecting minimum values.</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">bool</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">true</span></code></p>
</dd>
<dt class="field-odd">see also</dt>
<dd class="field-odd"><p><a class="reference internal" href="#confval-bluestore_cache_size"><code class="xref std std-confval docutils literal notranslate"><span class="pre">bluestore_cache_size</span></code></a>, <a class="reference internal" href="#confval-bluestore_cache_meta_ratio"><code class="xref std std-confval docutils literal notranslate"><span class="pre">bluestore_cache_meta_ratio</span></code></a></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-osd_memory_target">
<code class="sig-name descname"><span class="pre">osd_memory_target</span></code><a class="headerlink" href="#confval-osd_memory_target" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>When TCMalloc is available and cache autotuning is enabled, try to
keep this many bytes mapped in memory. Note: This may not exactly
match the RSS memory usage of the process.  While the total amount
of heap memory mapped by the process should usually be close
to this target, there is no guarantee that the kernel will actually
reclaim  memory that has been unmapped.  During initial development,
it was found that some kernels result in the OSD’s RSS memory
exceeding the mapped memory by up to 20%.  It is hypothesised
however, that the kernel generally may be more aggressive about
reclaiming unmapped memory when there is a high amount of memory
pressure.  Your mileage may vary.</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">size</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">4Gi</span></code></p>
</dd>
<dt class="field-odd">min</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">896_M</span></code></p>
</dd>
<dt class="field-even">see also</dt>
<dd class="field-even"><p><a class="reference internal" href="#confval-bluestore_cache_autotune"><code class="xref std std-confval docutils literal notranslate"><span class="pre">bluestore_cache_autotune</span></code></a>, <a class="reference internal" href="#confval-osd_memory_cache_min"><code class="xref std std-confval docutils literal notranslate"><span class="pre">osd_memory_cache_min</span></code></a>, <a class="reference internal" href="#confval-osd_memory_base"><code class="xref std std-confval docutils literal notranslate"><span class="pre">osd_memory_base</span></code></a>, <code class="xref std std-confval docutils literal notranslate"><span class="pre">osd_memory_target_autotune</span></code></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-bluestore_cache_autotune_interval">
<code class="sig-name descname"><span class="pre">bluestore_cache_autotune_interval</span></code><a class="headerlink" href="#confval-bluestore_cache_autotune_interval" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>The number of seconds to wait between rebalances when cache autotune
is enabled.  This setting changes how quickly the allocation ratios of
various caches are recomputed.  Note:  Setting this interval too small
can result in high CPU usage and lower performance.</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">float</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">5.0</span></code></p>
</dd>
<dt class="field-odd">see also</dt>
<dd class="field-odd"><p><a class="reference internal" href="#confval-bluestore_cache_autotune"><code class="xref std std-confval docutils literal notranslate"><span class="pre">bluestore_cache_autotune</span></code></a></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-osd_memory_base">
<code class="sig-name descname"><span class="pre">osd_memory_base</span></code><a class="headerlink" href="#confval-osd_memory_base" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>When TCMalloc and cache autotuning are enabled, estimate the minimum
amount of memory in bytes the OSD will need.  This is used to help the
autotuner estimate the expected aggregate memory consumption of the
caches.</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">size</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">768Mi</span></code></p>
</dd>
<dt class="field-odd">see also</dt>
<dd class="field-odd"><p><a class="reference internal" href="#confval-bluestore_cache_autotune"><code class="xref std std-confval docutils literal notranslate"><span class="pre">bluestore_cache_autotune</span></code></a></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-osd_memory_expected_fragmentation">
<code class="sig-name descname"><span class="pre">osd_memory_expected_fragmentation</span></code><a class="headerlink" href="#confval-osd_memory_expected_fragmentation" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>When TCMalloc and cache autotuning is enabled, estimate the percentage
of memory fragmentation.  This is used to help the autotuner estimate
the expected aggregate memory consumption of the caches.</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">float</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">0.15</span></code></p>
</dd>
<dt class="field-odd">allowed range</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">[0,</span> <span class="pre">1]</span></code></p>
</dd>
<dt class="field-even">see also</dt>
<dd class="field-even"><p><a class="reference internal" href="#confval-bluestore_cache_autotune"><code class="xref std std-confval docutils literal notranslate"><span class="pre">bluestore_cache_autotune</span></code></a></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-osd_memory_cache_min">
<code class="sig-name descname"><span class="pre">osd_memory_cache_min</span></code><a class="headerlink" href="#confval-osd_memory_cache_min" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>When TCMalloc and cache autotuning are enabled, set the minimum
amount of memory used for caches. Note: Setting this value too
low can result in significant cache thrashing.</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">size</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">128Mi</span></code></p>
</dd>
<dt class="field-odd">min</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">128_M</span></code></p>
</dd>
<dt class="field-even">see also</dt>
<dd class="field-even"><p><a class="reference internal" href="#confval-bluestore_cache_autotune"><code class="xref std std-confval docutils literal notranslate"><span class="pre">bluestore_cache_autotune</span></code></a></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-osd_memory_cache_resize_interval">
<code class="sig-name descname"><span class="pre">osd_memory_cache_resize_interval</span></code><a class="headerlink" href="#confval-osd_memory_cache_resize_interval" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>When TCMalloc and cache autotuning are enabled, wait this many seconds
between resizing caches.  This setting changes the total amount of
memory available for BlueStore to use for caching.  Note that setting
this interval too small can result in memory allocator thrashing and
lower performance.</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">float</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">1.0</span></code></p>
</dd>
<dt class="field-odd">see also</dt>
<dd class="field-odd"><p><a class="reference internal" href="#confval-bluestore_cache_autotune"><code class="xref std std-confval docutils literal notranslate"><span class="pre">bluestore_cache_autotune</span></code></a></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

</div>
<div class="section" id="id5">
<h2>手动调整缓存尺寸<a class="headerlink" href="#id5" title="Permalink to this headline">¶</a></h2>
<p>The amount of memory consumed by each OSD for BlueStore caches is
determined by the <code class="docutils literal notranslate"><span class="pre">bluestore_cache_size</span></code> configuration option.  If
that config option is not set (i.e., remains at 0), there is a
different default value that is used depending on whether an HDD or
SSD is used for the primary device (set by the
<code class="docutils literal notranslate"><span class="pre">bluestore_cache_size_ssd</span></code> and <code class="docutils literal notranslate"><span class="pre">bluestore_cache_size_hdd</span></code> config
options).</p>
<p>BlueStore and the rest of the Ceph OSD daemon do the best they can
to work within this memory budget.  Note that on top of the configured
cache size, there is also memory consumed by the OSD itself, and
some additional utilization due to memory fragmentation and other
allocator overhead.</p>
<p>The configured cache memory budget can be used in a few different ways:</p>
<ul class="simple">
<li><p>Key/Value metadata (i.e., RocksDB’s internal cache)</p></li>
<li><p>BlueStore metadata</p></li>
<li><p>BlueStore data (i.e., recently read or written object data)</p></li>
</ul>
<p>Cache memory usage is governed by the following options:
<code class="docutils literal notranslate"><span class="pre">bluestore_cache_meta_ratio</span></code> and <code class="docutils literal notranslate"><span class="pre">bluestore_cache_kv_ratio</span></code>.
The fraction of the cache devoted to data
is governed by the effective bluestore cache size (depending on
<code class="docutils literal notranslate"><span class="pre">bluestore_cache_size[_ssd|_hdd]</span></code> settings and the device class of the primary
device) as well as the meta and kv ratios.
The data fraction can be calculated by
<code class="docutils literal notranslate"><span class="pre">&lt;effective_cache_size&gt;</span> <span class="pre">*</span> <span class="pre">(1</span> <span class="pre">-</span> <span class="pre">bluestore_cache_meta_ratio</span> <span class="pre">-</span> <span class="pre">bluestore_cache_kv_ratio)</span></code></p>
<dl class="std confval">
<dt id="confval-bluestore_cache_size">
<code class="sig-name descname"><span class="pre">bluestore_cache_size</span></code><a class="headerlink" href="#confval-bluestore_cache_size" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>The amount of memory BlueStore will use for its cache.  If zero,
<code class="docutils literal notranslate"><span class="pre">bluestore_cache_size_hdd</span></code> or <code class="docutils literal notranslate"><span class="pre">bluestore_cache_size_ssd</span></code> will be
used instead.</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">size</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">0B</span></code></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-bluestore_cache_size_hdd">
<code class="sig-name descname"><span class="pre">bluestore_cache_size_hdd</span></code><a class="headerlink" href="#confval-bluestore_cache_size_hdd" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>The default amount of memory BlueStore will use for its cache when
backed by an HDD.</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">size</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">1Gi</span></code></p>
</dd>
<dt class="field-odd">see also</dt>
<dd class="field-odd"><p><a class="reference internal" href="#confval-bluestore_cache_size"><code class="xref std std-confval docutils literal notranslate"><span class="pre">bluestore_cache_size</span></code></a></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-bluestore_cache_size_ssd">
<code class="sig-name descname"><span class="pre">bluestore_cache_size_ssd</span></code><a class="headerlink" href="#confval-bluestore_cache_size_ssd" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>The default amount of memory BlueStore will use for its cache when
backed by an SSD.</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">size</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">3Gi</span></code></p>
</dd>
<dt class="field-odd">see also</dt>
<dd class="field-odd"><p><a class="reference internal" href="#confval-bluestore_cache_size"><code class="xref std std-confval docutils literal notranslate"><span class="pre">bluestore_cache_size</span></code></a></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-bluestore_cache_meta_ratio">
<code class="sig-name descname"><span class="pre">bluestore_cache_meta_ratio</span></code><a class="headerlink" href="#confval-bluestore_cache_meta_ratio" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>Ratio of bluestore cache to devote to metadata</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">float</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">0.45</span></code></p>
</dd>
<dt class="field-odd">see also</dt>
<dd class="field-odd"><p><a class="reference internal" href="#confval-bluestore_cache_size"><code class="xref std std-confval docutils literal notranslate"><span class="pre">bluestore_cache_size</span></code></a></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-bluestore_cache_kv_ratio">
<code class="sig-name descname"><span class="pre">bluestore_cache_kv_ratio</span></code><a class="headerlink" href="#confval-bluestore_cache_kv_ratio" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>Ratio of bluestore cache to devote to key/value database (RocksDB)</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">float</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">0.45</span></code></p>
</dd>
<dt class="field-odd">see also</dt>
<dd class="field-odd"><p><a class="reference internal" href="#confval-bluestore_cache_size"><code class="xref std std-confval docutils literal notranslate"><span class="pre">bluestore_cache_size</span></code></a></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

</div>
<div class="section" id="id6">
<h2>校验和<a class="headerlink" href="#id6" title="Permalink to this headline">¶</a></h2>
<p>BlueStore checksums all metadata and data written to disk.  Metadata
checksumming is handled by RocksDB and uses <cite>crc32c</cite>. Data
checksumming is done by BlueStore and can make use of <cite>crc32c</cite>,
<cite>xxhash32</cite>, or <cite>xxhash64</cite>.  The default is <cite>crc32c</cite> and should be
suitable for most purposes.</p>
<p>Full data checksumming does increase the amount of metadata that
BlueStore must store and manage.  When possible, e.g., when clients
hint that data is written and read sequentially, BlueStore will
checksum larger blocks, but in many cases it must store a checksum
value (usually 4 bytes) for every 4 kilobyte block of data.</p>
<p>It is possible to use a smaller checksum value by truncating the
checksum to two or one byte, reducing the metadata overhead.  The
trade-off is that the probability that a random error will not be
detected is higher with a smaller checksum, going from about one in
four billion with a 32-bit (4 byte) checksum to one in 65,536 for a
16-bit (2 byte) checksum or one in 256 for an 8-bit (1 byte) checksum.
The smaller checksum values can be used by selecting <cite>crc32c_16</cite> or
<cite>crc32c_8</cite> as the checksum algorithm.</p>
<p>The <em>checksum algorithm</em> can be set either via a per-pool
<code class="docutils literal notranslate"><span class="pre">csum_type</span></code> property or the global config option.  For example,</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="o">&lt;</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="o">&gt;</span> <span class="n">csum_type</span> <span class="o">&lt;</span><span class="n">algorithm</span><span class="o">&gt;</span>
</pre></div>
</div>
<dl class="std confval">
<dt id="confval-bluestore_csum_type">
<code class="sig-name descname"><span class="pre">bluestore_csum_type</span></code><a class="headerlink" href="#confval-bluestore_csum_type" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>The default checksum algorithm to use.</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">str</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">crc32c</span></code></p>
</dd>
<dt class="field-odd">valid choices</dt>
<dd class="field-odd"><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">none</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">crc32c</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">crc32c_16</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">crc32c_8</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">xxhash32</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">xxhash64</span></code></p></li>
</ul>
</dd>
</dl>
</div></blockquote>
</dd></dl>

</div>
<div class="section" id="id7">
<h2>内联压缩<a class="headerlink" href="#id7" title="Permalink to this headline">¶</a></h2>
<p>BlueStore 支持内联压缩，可用 <cite>snappy</cite> 、 <cite>zlib</cite> 或 <cite>lz4</cite>
压缩算法。请注意， <cite>lz4</cite> 压缩插件不在官方发布内。</p>
<p>Whether data in BlueStore is compressed is determined by a combination
of the <em>compression mode</em> and any hints associated with a write
operation.  The modes are:</p>
<ul class="simple">
<li><p><strong>none</strong>: 永不压缩数据；</p></li>
<li><p><strong>passive</strong>: Do not compress data unless the write operation has a
<em>compressible</em> hint set.</p></li>
<li><p><strong>aggressive</strong>: Compress data unless the write operation has an
<em>incompressible</em> hint set.</p></li>
<li><p><strong>force</strong>: 压缩一切数据。</p></li>
</ul>
<p>For more information about the <em>compressible</em> and <em>incompressible</em> IO
hints, see <a class="reference internal" href="../../api/librados/#c.rados_set_alloc_hint" title="rados_set_alloc_hint"><code class="xref c c-func docutils literal notranslate"><span class="pre">rados_set_alloc_hint()</span></code></a>.</p>
<p>Note that regardless of the mode, if the size of the data chunk is not
reduced sufficiently it will not be used and the original
(uncompressed) data will be stored.  For example, if the <code class="docutils literal notranslate"><span class="pre">bluestore</span>
<span class="pre">compression</span> <span class="pre">required</span> <span class="pre">ratio</span></code> is set to <code class="docutils literal notranslate"><span class="pre">.7</span></code> then the compressed data
must be 70% of the size of the original (or smaller).</p>
<p>The <em>compression mode</em>, <em>compression algorithm</em>, <em>compression required
ratio</em>, <em>min blob size</em>, and <em>max blob size</em> can be set either via a
per-pool property or a global config option.  Pool properties can be
set with:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="o">&lt;</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="o">&gt;</span> <span class="n">compression_algorithm</span> <span class="o">&lt;</span><span class="n">algorithm</span><span class="o">&gt;</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="o">&lt;</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="o">&gt;</span> <span class="n">compression_mode</span> <span class="o">&lt;</span><span class="n">mode</span><span class="o">&gt;</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="o">&lt;</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="o">&gt;</span> <span class="n">compression_required_ratio</span> <span class="o">&lt;</span><span class="n">ratio</span><span class="o">&gt;</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="o">&lt;</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="o">&gt;</span> <span class="n">compression_min_blob_size</span> <span class="o">&lt;</span><span class="n">size</span><span class="o">&gt;</span>
<span class="n">ceph</span> <span class="n">osd</span> <span class="n">pool</span> <span class="nb">set</span> <span class="o">&lt;</span><span class="n">pool</span><span class="o">-</span><span class="n">name</span><span class="o">&gt;</span> <span class="n">compression_max_blob_size</span> <span class="o">&lt;</span><span class="n">size</span><span class="o">&gt;</span>
</pre></div>
</div>
<dl class="std confval">
<dt id="confval-bluestore_compression_algorithm">
<code class="sig-name descname"><span class="pre">bluestore_compression_algorithm</span></code><a class="headerlink" href="#confval-bluestore_compression_algorithm" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>The default compressor to use (if any) if the per-pool property
<code class="docutils literal notranslate"><span class="pre">compression_algorithm</span></code> is not set. Note that <code class="docutils literal notranslate"><span class="pre">zstd</span></code> is <em>not</em>
recommended for BlueStore due to high CPU overhead when compressing
small amounts of data.</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">str</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">snappy</span></code></p>
</dd>
<dt class="field-odd">valid choices</dt>
<dd class="field-odd"><ul class="simple">
<li><p>&lt;empty string&gt;</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">snappy</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">zlib</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">zstd</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">lz4</span></code></p></li>
</ul>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-bluestore_compression_mode">
<code class="sig-name descname"><span class="pre">bluestore_compression_mode</span></code><a class="headerlink" href="#confval-bluestore_compression_mode" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>The default policy for using compression if the per-pool property
<code class="docutils literal notranslate"><span class="pre">compression_mode</span></code> is not set. <code class="docutils literal notranslate"><span class="pre">none</span></code> means never use compression.
<code class="docutils literal notranslate"><span class="pre">passive</span></code> means use compression when <a class="reference internal" href="../../api/librados/#c.rados_set_alloc_hint" title="rados_set_alloc_hint"><code class="xref c c-func docutils literal notranslate"><span class="pre">clients</span> <span class="pre">hint</span></code></a> that data is compressible.  <code class="docutils literal notranslate"><span class="pre">aggressive</span></code>
means use compression unless clients hint that data is not
compressible.  <code class="docutils literal notranslate"><span class="pre">force</span></code> means use compression under all circumstances
even if the clients hint that the data is not compressible.</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">str</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">none</span></code></p>
</dd>
<dt class="field-odd">valid choices</dt>
<dd class="field-odd"><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">none</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">passive</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">aggressive</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">force</span></code></p></li>
</ul>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-bluestore_compression_required_ratio">
<code class="sig-name descname"><span class="pre">bluestore_compression_required_ratio</span></code><a class="headerlink" href="#confval-bluestore_compression_required_ratio" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>为了存得下压缩后的版本，压缩后的数据块尺寸与原始尺寸的比率必须小于此数值。</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">float</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">0.875</span></code></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-bluestore_compression_min_blob_size">
<code class="sig-name descname"><span class="pre">bluestore_compression_min_blob_size</span></code><a class="headerlink" href="#confval-bluestore_compression_min_blob_size" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>Chunks smaller than this are never compressed. The per-pool property
<code class="docutils literal notranslate"><span class="pre">compression_min_blob_size</span></code> overrides this setting.</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">size</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">0B</span></code></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-bluestore_compression_min_blob_size_hdd">
<code class="sig-name descname"><span class="pre">bluestore_compression_min_blob_size_hdd</span></code><a class="headerlink" href="#confval-bluestore_compression_min_blob_size_hdd" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>Default value of <code class="docutils literal notranslate"><span class="pre">bluestore</span> <span class="pre">compression</span> <span class="pre">min</span> <span class="pre">blob</span> <span class="pre">size</span></code> for
rotational media.</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">size</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">8Ki</span></code></p>
</dd>
<dt class="field-odd">see also</dt>
<dd class="field-odd"><p><a class="reference internal" href="#confval-bluestore_compression_min_blob_size"><code class="xref std std-confval docutils literal notranslate"><span class="pre">bluestore_compression_min_blob_size</span></code></a></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-bluestore_compression_min_blob_size_ssd">
<code class="sig-name descname"><span class="pre">bluestore_compression_min_blob_size_ssd</span></code><a class="headerlink" href="#confval-bluestore_compression_min_blob_size_ssd" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>Default value of <code class="docutils literal notranslate"><span class="pre">bluestore</span> <span class="pre">compression</span> <span class="pre">min</span> <span class="pre">blob</span> <span class="pre">size</span></code> for non-
rotational (solid state) media.</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">size</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">8Ki</span></code></p>
</dd>
<dt class="field-odd">see also</dt>
<dd class="field-odd"><p><a class="reference internal" href="#confval-bluestore_compression_min_blob_size"><code class="xref std std-confval docutils literal notranslate"><span class="pre">bluestore_compression_min_blob_size</span></code></a></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-bluestore_compression_max_blob_size">
<code class="sig-name descname"><span class="pre">bluestore_compression_max_blob_size</span></code><a class="headerlink" href="#confval-bluestore_compression_max_blob_size" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>Chunks larger than this value are broken into smaller blobs of at most
<code class="docutils literal notranslate"><span class="pre">bluestore_compression_max_blob_size</span></code> bytes before being compressed.
The per-pool property <code class="docutils literal notranslate"><span class="pre">compression_max_blob_size</span></code> overrides this
setting.</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">size</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">0B</span></code></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-bluestore_compression_max_blob_size_hdd">
<code class="sig-name descname"><span class="pre">bluestore_compression_max_blob_size_hdd</span></code><a class="headerlink" href="#confval-bluestore_compression_max_blob_size_hdd" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>Default value of <code class="docutils literal notranslate"><span class="pre">bluestore</span> <span class="pre">compression</span> <span class="pre">max</span> <span class="pre">blob</span> <span class="pre">size</span></code> for
rotational media.</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">size</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">64Ki</span></code></p>
</dd>
<dt class="field-odd">see also</dt>
<dd class="field-odd"><p><a class="reference internal" href="#confval-bluestore_compression_max_blob_size"><code class="xref std std-confval docutils literal notranslate"><span class="pre">bluestore_compression_max_blob_size</span></code></a></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-bluestore_compression_max_blob_size_ssd">
<code class="sig-name descname"><span class="pre">bluestore_compression_max_blob_size_ssd</span></code><a class="headerlink" href="#confval-bluestore_compression_max_blob_size_ssd" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>用非旋转（SSD 、 NVMe）媒体时 <code class="docutils literal notranslate"><span class="pre">bluestore</span> <span class="pre">compression</span> <span class="pre">max</span> <span class="pre">blob</span> <span class="pre">size</span></code> 的默认值。</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">size</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">64Ki</span></code></p>
</dd>
<dt class="field-odd">see also</dt>
<dd class="field-odd"><p><a class="reference internal" href="#confval-bluestore_compression_max_blob_size"><code class="xref std std-confval docutils literal notranslate"><span class="pre">bluestore_compression_max_blob_size</span></code></a></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

</div>
<div class="section" id="rocksdb-sharding">
<span id="bluestore-rocksdb-sharding"></span><h2>RocksDB Sharding<a class="headerlink" href="#rocksdb-sharding" title="Permalink to this headline">¶</a></h2>
<p>Internally BlueStore uses multiple types of key-value data,
stored in RocksDB.  Each data type in BlueStore is assigned a
unique prefix. Until Pacific all key-value data was stored in
single RocksDB column family: ‘default’.  Since Pacific,
BlueStore can divide this data into multiple RocksDB column
families. When keys have similar access frequency, modification
frequency and lifetime, BlueStore benefits from better caching
and more precise compaction. This improves performance, and also
requires less disk space during compaction, since each column
family is smaller and can compact independent of others.</p>
<p>OSDs deployed in Pacific or later use RocksDB sharding by default.
If Ceph is upgraded to Pacific from a previous version, sharding is off.</p>
<p>To enable sharding and apply the Pacific defaults, stop an OSD and run</p>
<blockquote>
<div><div class="highlight-default notranslate"><div class="highlight"><pre><style type="text/css">
span.prompt1:before {
  content: "# ";
}
</style><span class="prompt1">ceph-bluestore-tool <span class="se">\</span>
  --path &lt;data path&gt; <span class="se">\</span>
  --sharding<span class="o">=</span><span class="s2">&quot;m(3) p(3,0-12) O(3,0-13)=block_cache={type=binned_lru} L P&quot;</span> <span class="se">\</span>
  reshard</span>
</pre></div></div></div></blockquote>
<dl class="std confval">
<dt id="confval-bluestore_rocksdb_cf">
<code class="sig-name descname"><span class="pre">bluestore_rocksdb_cf</span></code><a class="headerlink" href="#confval-bluestore_rocksdb_cf" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>Enables sharding of BlueStore’s RocksDB. When <code class="docutils literal notranslate"><span class="pre">true</span></code>,
<code class="docutils literal notranslate"><span class="pre">bluestore_rocksdb_cfs</span></code> is used. Only applied when OSD is doing
<code class="docutils literal notranslate"><span class="pre">--mkfs</span></code>.</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">bool</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">true</span></code></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-bluestore_rocksdb_cfs">
<code class="sig-name descname"><span class="pre">bluestore_rocksdb_cfs</span></code><a class="headerlink" href="#confval-bluestore_rocksdb_cfs" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>Definition of BlueStore’s RocksDB sharding. The optimal value depends
on multiple factors, and modification is invadvisable. This setting is
used only when OSD is doing <code class="docutils literal notranslate"><span class="pre">--mkfs</span></code>. Next runs of OSD retrieve
sharding from disk.</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">str</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">m(3)</span> <span class="pre">p(3,0-12)</span> <span class="pre">O(3,0-13)=block_cache={type=binned_lru}</span> <span class="pre">L</span> <span class="pre">P</span></code></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

</div>
<div class="section" id="throttling">
<h2>Throttling<a class="headerlink" href="#throttling" title="Permalink to this headline">¶</a></h2>
<dl class="std confval">
<dt id="confval-bluestore_throttle_bytes">
<code class="sig-name descname"><span class="pre">bluestore_throttle_bytes</span></code><a class="headerlink" href="#confval-bluestore_throttle_bytes" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>Maximum bytes in flight before we throttle IO submission</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">size</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">64Mi</span></code></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-bluestore_throttle_deferred_bytes">
<code class="sig-name descname"><span class="pre">bluestore_throttle_deferred_bytes</span></code><a class="headerlink" href="#confval-bluestore_throttle_deferred_bytes" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>Maximum bytes for deferred writes before we throttle IO submission</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">size</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">128Mi</span></code></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-bluestore_throttle_cost_per_io">
<code class="sig-name descname"><span class="pre">bluestore_throttle_cost_per_io</span></code><a class="headerlink" href="#confval-bluestore_throttle_cost_per_io" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>Overhead added to transaction cost (in bytes) for each IO</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">size</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">0B</span></code></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-bluestore_throttle_cost_per_io_hdd">
<code class="sig-name descname"><span class="pre">bluestore_throttle_cost_per_io_hdd</span></code><a class="headerlink" href="#confval-bluestore_throttle_cost_per_io_hdd" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>Default bluestore_throttle_cost_per_io for rotational media</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">uint</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">670000</span></code></p>
</dd>
<dt class="field-odd">see also</dt>
<dd class="field-odd"><p><a class="reference internal" href="#confval-bluestore_throttle_cost_per_io"><code class="xref std std-confval docutils literal notranslate"><span class="pre">bluestore_throttle_cost_per_io</span></code></a></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="std confval">
<dt id="confval-bluestore_throttle_cost_per_io_ssd">
<code class="sig-name descname"><span class="pre">bluestore_throttle_cost_per_io_ssd</span></code><a class="headerlink" href="#confval-bluestore_throttle_cost_per_io_ssd" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>Default bluestore_throttle_cost_per_io for non-rotation (solid state)
media</p>
<dl class="field-list simple">
<dt class="field-odd">type</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">uint</span></code></p>
</dd>
<dt class="field-even">default</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">4000</span></code></p>
</dd>
<dt class="field-odd">see also</dt>
<dd class="field-odd"><p><a class="reference internal" href="#confval-bluestore_throttle_cost_per_io"><code class="xref std std-confval docutils literal notranslate"><span class="pre">bluestore_throttle_cost_per_io</span></code></a></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

</div>
<div class="section" id="spdk">
<h2>SPDK 用法<a class="headerlink" href="#spdk" title="Permalink to this headline">¶</a></h2>
<p>如果你想让 NVMe SSD 使用 SPDK 驱动，你得先配置好系统。详情见
<a class="reference external" href="http://www.spdk.io/doc/getting_started.html#getting_started_examples">SPDK 文档</a>。</p>
<p>SPDK 有个脚本可以自动配置设备，以 root 身份执行：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo src/spdk/scripts/setup.sh
</pre></div>
</div>
<p>之后你需要在这里给 <code class="docutils literal notranslate"><span class="pre">bluestore_block_path</span></code> 指定 NVMe 设备的设备档位，它以 spdk: 为前缀。</p>
<p>例如，你可以这样找出一个 Intel PCIe SSD 的设备档位：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ lspci -mm -n -D -d 8086:0953
</pre></div>
</div>
<p>设备档位的格式肯定是 <code class="docutils literal notranslate"><span class="pre">DDDD:BB:DD.FF</span></code> 或 <code class="docutils literal notranslate"><span class="pre">DDDD.BB.DD.FF</span></code> 。</p>
<p>然后这样设置：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">bluestore</span> <span class="n">block</span> <span class="n">path</span> <span class="o">=</span> <span class="n">spdk</span><span class="p">:</span><span class="mi">0000</span><span class="p">:</span><span class="mi">01</span><span class="p">:</span><span class="mf">00.0</span>
</pre></div>
</div>
<p>其中， <code class="docutils literal notranslate"><span class="pre">0000:01:00.0</span></code> 就是在前面 <code class="docutils literal notranslate"><span class="pre">lspci</span></code> 命令的输出里找到的。</p>
<p>If you want to run multiple SPDK instances per node, you must specify the
amount of dpdk memory size in MB each instance will use, to make sure each
instance uses its own dpdk memory</p>
<p>In most cases, we only need one device to serve as data, db, db wal purposes.
We need to make sure configurations below to make sure all IOs issued under
SPDK.:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">bluestore_block_db_path</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
<span class="n">bluestore_block_db_size</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">bluestore_block_wal_path</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
<span class="n">bluestore_block_wal_size</span> <span class="o">=</span> <span class="mi">0</span>
</pre></div>
</div>
<p>Otherwise, the current implementation will setup symbol file to kernel
filesystem location and uses kernel driver to issue DB/WAL IO.</p>
</div>
</div>



           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="../filestore-config-ref/" class="btn btn-neutral float-right" title="filestore 配置参考" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="../mclock-config-ref/" class="btn btn-neutral float-left" title="mClock Config Reference" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).

    </p>
  </div> 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>